package com.sgb.kjwl.viewmodel.business;

import com.sgb.kjwl.api.APIManager;
import com.sgb.kjwl.model.entity.business.MemberDetailEntity;
import com.sgb.kjwl.repository.SelfRepertory;
import com.sgb.kjwl.view.ui.fragment.business.MemberDetailFragment;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.model.entity.BaseEntity;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MemberDetailFragModel extends BaseViewModel {

    private final MemberDetailFragment fragment;

    public MemberDetailFragModel(MemberDetailFragment fragment, SelfRepertory selfRepertory) {
        this.fragment = fragment;
    }

    public void getMemberCompanyDetail(String id) {
       APIManager.getInstance().getBusinessManagementAPI().getMemberCompanyDetail(id).enqueue(new Callback<BaseEntity<MemberDetailEntity>>() {
           @Override
           public void onResponse(Call<BaseEntity<MemberDetailEntity>> call, Response<BaseEntity<MemberDetailEntity>> response) {
               if (response.body()==null || response.body().getData()==null){
                   return;
               }

               fragment.showData(response.body().getData());
           }

           @Override
           public void onFailure(Call<BaseEntity<MemberDetailEntity>> call, Throwable t) {

           }
       });


    }
}
